package com.zjitc.service;

import com.zjitc.vo.ForgetPasswordDemo;
import com.zjitc.vo.PageModel;
import com.zjitc.common.ServerResponse;
import com.zjitc.pojo.User;

import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import org.springframework.web.servlet.ModelAndView;

/**
 * Create By IntelliJ IDEA
 *
 * @author: myq
 * @create-Time: 2017/11/7  15:55
 */
public interface UserService {
  /**
   * 注册
   * @param user
   * @param path
   * @return
   */
  boolean regiser(User user, String path);

  /**
   * 激活
   * @param uid
   * @param code
   * @return
   */
  boolean active(String uid, String code);


  /**
   * 登陆
   * @param username
   * @param password
   * @param code
   * @param session
   * @return
   * @throws UnsupportedEncodingException
   * @throws NoSuchAlgorithmException
   */
  ServerResponse<User> login(String username, String password, String code, HttpSession session) throws UnsupportedEncodingException, NoSuchAlgorithmException;

  /**
   * 管理员登陆
   * @param username
   * @param password
   * @return
   */
  User adminLogin(String username, String password);
  /**
   * 检查用户名是否被占用
   * @param username
   * @return
   */
  ServerResponse<User> checkUsername(String username);

  /**
   * 查看所有用户信息
   * @param pageid
   * @param count
   * @return
   */
  PageModel<User> findall(int pageid, int count);

  /**
   * 更新用户信息
   * @param user
   */
  void update(User user);

  /**
   * 查看用户
   * @param uid
   * @return
   */
  User findbyuid(String uid);

  /**
   * 删除用户
   * @param uid
   */
  void deluser(String uid);

  /**
   * 确认密码
   * @param password
   * @param verifypassword
   * @return
   */
  ServerResponse checkpassword(String password, String verifypassword);

  /**
   * 发送邮件验证
   * @param demo
   */
  void forgetSendEmail(ForgetPasswordDemo demo);

  /**
   * 检查对应验证码是否正确
   * @param demo
   * @param code
   * @return
   */
  ServerResponse forgetcheckcode(ForgetPasswordDemo demo, String code);

  /**
   * 通过username 找到 对应的uid
   * @param username
   * @return
   */
  String finduidByusername(String username);

  /**
   * 忘记密码的重置密码
   * @param user
   * @return
   */
  boolean forgetResetPassword(User user);

  /**
   * 重置密码
   * @param uid
   * @param oldPassword
   * @param newPassword
   * @param session
   * @return
   */
  ServerResponse resetPassword(String uid, String oldPassword, String newPassword,HttpSession session);

  /**
   * 查看用户收藏商品
   * @param session
   * @param page
   * @return
   */
  ModelAndView searchMyCollect(HttpSession session, String page);
}
